//
//  SwiftUIView.swift
//  
//
//  Created by xxs on 2024/9/11.
//

import SwiftUI
import AppIntents

struct IntentButton<Label>: View where Label: View {

    var intent: (any AppIntent)?
    var label: () -> Label

    var body: some View {
        #if os(iOS)
        if #available(iOS 17.0, *) {
            if let intent = intent {
                return Button(intent: intent, label: label).buttonStyle(.plain)
            }
        }
        #else
        if #available(macOS 14.0, *) {
            if let intent = intent {
                return Button(intent: intent, label: label).buttonStyle(.plain)
            }
        }
        #endif
        return Button(action: {}, label: label).buttonStyle(.plain)
    }
}
